﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using aerowan.common.Network;
using aerowan.server.Network.Packets;

namespace aerowan.server.Network
{
    public class PilotLayer
    {
        public static PilotLayer Instance { get; private set; }
        static PilotLayer()
        {
            Instance = new PilotLayer();
        }

        NetworkServer NetServer;

        PilotLayer()
        {
            // InitPackets
            PacketTypeManager.RegisterClientPacketType(0x04, typeof(CSPkt_Login));

            NetServer = new NetworkServer(IPAddress.Parse("0.0.0.0"), 8477);
            NetServer.Start();
        }

        public bool CallsignExists(string call)
        {
            return NetServer.Clients.Where(c => c.Attachment is PilotConnectionData && (c.Attachment as PilotConnectionData).Callsign == call).FirstOrDefault() != null;
        }
    }
}
